#include "plain-matching.h"

int Index(char *S,const char *T,int *pos){
    int i = *pos;
    while (*S && i){    //Check First,or you will overflow
        S++;
        --i;
    }

    while (*S){
        while (*(T+i)){
            if (*(S + i) != *(T + i)){
                i = 0;
                break;
            } else{
                i++;
            }
        }
        if (*(T+i)){
            S++;
            (*pos)++;
        }else{
            break;
        }
    }

    if (*S){
        return(0);
    } else{
        return(-1);
    }

}
